<?php

namespace app\api\controller;

use app\api\service\LoginService;
use app\BaseController;
use think\facade\Request;
use app\Response;

class Login extends BaseController
{
    public function login(){
        if(Request::method() == 'POST'){
            $data = Request::param();//account 与 password
            try{
                $this->validate($data, 'UserLogin');
            }catch (\Exception $e){
                return Response::wrapError(0,$e->getMessage());
            }
            $res = LoginService::loginService($data);
            return $res;
        }
    }

    public function userInfo(){
        if(Request::method() == 'POST'){
            $uid = Request::param("uid");
            $res = LoginService::useInfoService($uid);
            return $res;
        }
    }


    public function editPassword(){
        if(Request::method() == 'POST'){
            $uid = Request::param("uid");
            $password = Request::param("password");
            $res = LoginService::useEdisPassword($uid,$password);
            return $res;
        }
    }
}